The insert method inserts a new floating value at the specified index for the in-memory dataset of a given StudyData object.
insert(index, floatValue);
index
Index specifies the location where to insert the floating value.
floatValue
Floating value that will be inserted and stored in memory.
The following example demonstrates how to insert a value into a StudyData object.
function calculate(beginIndex, endIndex)
{
var studyData = this.getStudyData("customSMA");
if(studyData != null)
{
//calculate new value and insert it at the end
var newValue = calculateRandomValue();
studyData.insert(studyData.count(), newValue);
}
}
function calculateRandomValue()
{
//calculate some random value, and return it to the caller
var randomValue = Math.rand();
return randomValue;
}
Copyright © 2006-2009 ActiveTick LLC